<template>
	<view class="yajinrecord">
		<headertop title="押金记录" str1="oridei" :back1="back1"></headertop>
		<view class="yajinrecordback">

		</view>
		<view class="seachbox">
			<image src="https://39gongli.oss-cn-beijing.aliyuncs.com/static/Frame@2x (1).png" class="lefticon" mode="">
			</image>
			<input type="text" v-model="query.keywords" placeholder="请输入关键词进行搜索" />

			<view class="seachboxbtn" @click="init('搜索')">
				搜索
			</view>
			<image src="/static/Frame@2x(15).png" class="closeicon" @click="closeinput" v-if="query.keywords" mode="">
			</image>
		</view>
		<view class="classifybox">
			<view :class="active==0?'itembox activecolor':'itembox'" @click="qiehuan(0)">
				<span>全部</span>
				<view class="activebox" v-if="active==0">

				</view>
			</view>
			<view :class="active==1?'itembox activecolor':'itembox'" @click="qiehuan(1)">
				<span>可退押</span>
				<view class="activebox" v-if="active==1">

				</view>
			</view>
			<view :class="active==2?'itembox activecolor':'itembox'" @click="qiehuan(2)">
				<span>进行中</span>
				<view class="activebox" v-if="active==2">

				</view>
			</view>
			<view :class="active==3?'itembox activecolor':'itembox'" @click="qiehuan(3)">
				<span>审核中</span>
				<view class="activebox" v-if="active==3">

				</view>
			</view>
			<view :class="active==4?'itembox activecolor':'itembox'" @click="qiehuan(4)">
				<span>已完成</span>
				<view class="activebox" v-if="active==4">

				</view>
			</view>
		</view>
		<view class="itemboxss">
			<view class="msgicon" v-if="!list.length">
				<image src="/static/微信图片_20250514232056.png" mode="widthFix"></image>
				<view class="msgtext">
					暂无记录
				</view>
			</view>
			<view class="itembox" v-for="item  in list" :key="item.id">
				<view class="itembox_center" v-if="item.file">
					<view class="topline">
						<view class="dingdanbinhao">
							<image src="https://39gongli.oss-cn-beijing.aliyuncs.com/static/微信图片_20250429143332.png"
								class="dingdanbinhao_icon" mode=""></image>
							<span>订单编号：{{item.file.order_no}}</span>
						</view>
						<view class="statustext">
							{{statustext(item.status)}}
						</view>
					</view>
					<view class="spinfo" v-if="item.type==3" v-for="ite in item.goods" :key="ite.id">
						<image :src="ite.image" mode=""></image>
						<view class="text1">
							<view class="l1">
								<view class="box" v-if="ite.typename">
									固
								</view>
								<span>{{ite.cname}}</span>
							</view>
							<view class="l2">
								{{ite.detail}}
							</view>
							<view class="yajinbox">
								押金 <span
									style="font-weight: bold;font-size: 36rpx;color: #7EBC79;">￥{{ite.deposit}}</span>
							</view>
						</view>
					</view>
					<view class="spinfo" v-if="item.type==2||item.type==4" v-for="ite in item.goods" :key="ite.id">
						<image :src="ite.image" mode=""></image>
						<view class="text1">
							<view class="l1">
								<span>{{ite.title}}</span>
							</view>
							<view class="l2">
								{{ite.detail}}
							</view>
							<view class="yajinbox">
								押金 <span
									style="font-weight: bold;font-size: 36rpx;color: #7EBC79;">￥{{ite.deposit}}</span>
							</view>
						</view>
					</view>

					<view class="bottomline" v-if="statustext(item.status)=='可退押'" @click="gotui(item)">
						<view class="btn">
							申请退押
						</view>
					</view>
					<view class="bottomline" v-else style="height:28rpx;border:none;">

					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script setup>
	import headertop from '@/components/header.vue'
	import {
		yjlog
	} from '@/api/my.js'
	import {
		onPageScroll,
		onLoad
	} from "@dcloudio/uni-app";
	import {
		ref,
		reactive
	} from 'vue'
	const back1 = ref('')
	const active = ref(0)
	const list = ref([])
	const lastpage = ref('')
	const query = reactive({
		page: 1,
		limit: 10,
		keywords: '',
		status: 0
	})
	onLoad(() => {
		init()
	})

	function closeinput() {
		query.keywords = ''
		query.status = 0
		active.value = 0
		query.page = 1
		list.value = []
		init()
	}

	function gotui(item) {
		uni.setStorageSync('itemobj', item)
		if (item.type == 2 || item.type == 4) {
			uni.navigateTo({
				url: '/sub_my/my/tuiyajin?id=' + item.file.id + '&typestr=zuli'
			})
		} else {
			uni.navigateTo({
				url: '/sub_my/my/tuiyajin?id=' + item.file.id
			})
		}

	}

	function qiehuan(index) {
		query.status = index
		active.value = index
		query.page = 1
		list.value = []
		init()
	}
	onPageScroll((e) => {
		console.log(e, 'eeeeeeeeeeeeeee');
		if (e.scrollTop > 100) {
			back1.value = '#84BD78'
		} else {
			back1.value = ''
		}
		if (lastpage.value > query.page) {
			query.page++
			init()
		}
	})

	function statustext(num) {
		if (num == '0') {
			return '待使用'
		} else if (num == '1') {
			return '使用中'
		} else if (num == '2') {
			return '待退还'
		} else if (num == '3') {
			return '可退押'
		} else if (num == '4') {
			return '进行中'
		} else if (num == '5') {
			return '审核中'
		} else if (num == '6') {
			return '已完成'
		}
	}
	async function init(str) {
		if (str == '搜索') {
			query.status = 0
			query.page = 1
			list.value = []
		}
		const res = await yjlog(query)
		if (res.data.code == 1) {
			list.value.push(...res.data.data.list)
			console.log(list.value, 'list.valuelist.valuelist.valuelist.value');
			lastpage.value = res.data.data.lastpage
		}
	}
</script>

<style lang="scss">
	.closeicon {
		width: 40rpx;
		height: 40rpx;
		margin-left: 80rpx;
	}

	.msgicon {
		width: 532rpx;
		margin: 100rpx auto;
		overflow: hidden;

		.msgtext {
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #4E5969;
			text-align: center;
			width: 100%;
			margin-top: -30rpx;
		}

		image {
			width: 532rpx;
		}
	}

	page {
		background: #F7F8FA;
	}

	.activecolor {
		color: #7EBC79 !important;
	}

	.yajinrecord {
		width: 100%;
		position: relative;
		overflow: hidden;

		.itemboxss {
			width: 686rpx;
			margin: auto;
			overflow: hidden;
			margin-top: 30rpx;

			.itembox {
				width: 686rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(0, 0, 0, 0.18);
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				margin-bottom: 28rpx;

				&_center {
					width: 630rpx;
					margin: auto;
					overflow: hidden;

					.bottomline {
						width: 100%;
						overflow: hidden;
						height: 124rpx;
						border-top: 1rpx solid #C9CDD4;
						display: flex;
						align-items: center;
						margin-top: 28rpx;

						.btn {
							width: 190rpx;
							height: 64rpx;
							background: rgba(126, 188, 121, 0.2);
							border-radius: 8rpx 8rpx 8rpx 8rpx;
							text-align: center;
							line-height: 64rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: bold;
							font-size: 28rpx;
							color: #7EBC79;
							margin-left: 440rpx;
						}
					}

					.spinfo {
						width: 100%;
						overflow: hidden;
						margin-top: 36rpx;
						display: flex;
						align-items: center;

						image {
							width: 162rpx;
							height: 144rpx;
							border-radius: 20rpx 20rpx 20rpx 20rpx;
						}

						.text1 {
							width: 452rpx;
							margin-left: 16rpx;
							overflow: hidden;

							.l1 {
								display: flex;
								align-items: center;
								font-family: PingFang SC, PingFang SC;
								font-weight: 500;
								font-size: 28rpx;
								color: #1D2129;

								.box {
									width: 48rpx;
									height: 32rpx;
									background: #7EBC79;
									border-radius: 4rpx 16rpx 4rpx 16rpx;
									font-family: PingFang SC, PingFang SC;
									font-weight: 500;
									font-size: 24rpx;
									color: #FFFFFF;
									text-align: center;
									line-height: 32rpx;
									margin-right: 8rpx;
								}
							}

							.l2 {
								font-family: PingFang SC, PingFang SC;
								font-weight: 400;
								font-size: 24rpx;
								color: #7F7F7F;
								overflow: hidden;
								word-break: break-all;
								white-space: nowrap;
								margin-top: 18rpx;
								width: 408rpx;
							}

							.yajinbox {
								display: flex;
								align-items: center;
								margin-top: 28rpx;
								font-family: PingFang SC, PingFang SC;
								font-weight: 400;
								font-size: 24rpx;
								color: #86909C;
								margin-left: 232rpx;
							}
						}
					}

					.topline {
						width: 100%;
						display: flex;
						align-items: center;
						justify-content: space-between;
						margin-top: 28rpx;

						.dingdanbinhao {
							width: 80%;
							word-break: break-all;
							/* 或 */
							display: flex;
							align-items: center;
							font-family: PingFang SC, PingFang SC;
							font-weight: 500;
							font-size: 28rpx;
							color: #1D2129;

							&_icon {
								width: 24rpx;
								height: 27rpx;
								margin-right: 12rpx;
							}
						}

						.statustext {
							font-family: PingFang SC, PingFang SC;
							font-weight: 500;
							font-size: 32rpx;
							color: #FF7613;
						}
					}


				}
			}
		}

		.yajinrecordback {
			width: 100%;
			height: 530rpx;
			background: linear-gradient(180deg, #84BD78 0%, rgba(132, 189, 120, 0) 100%);
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			position: absolute;
			z-index: -1;
		}

		.classifybox {
			width: 686rpx;
			margin: auto;
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 40rpx;

			.itembox {
				width: 96rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 32rpx;
				color: #1D2129;
				position: relative;
				margin-bottom: 28rpx;
				display: flex;
				flex-direction: column;
				align-items: center;

				.activebox {
					width: 48rpx;
					height: 6rpx;
					background: #7EBC79;
					border-radius: 4rpx 4rpx 4rpx 4rpx;
					position: absolute;
					bottom: -70%;
					margin-top: 10rpx;
				}
			}
		}

		.seachbox {
			width: 686rpx;
			margin: auto;
			margin-top: 186rpx;
			height: 68rpx;
			background: rgba(255, 255, 255, 0.9);
			border-radius: 34rpx 34rpx 34rpx 34rpx;
			display: flex;
			align-items: center;
			position: relative;

			.lefticon {
				margin-left: 20rpx;
				width: 32rpx;
				height: 32rpx;
			}

			input {
				margin-left: 16rpx;
			}

			.seachboxbtn {
				width: 120rpx;
				height: 68rpx;
				background: #7EBC79;
				border-radius: 34rpx 34rpx 34rpx 34rpx;
				text-align: center;
				line-height: 68rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				position: absolute;
				color: #FFFFFF;
				right: 0%;
			}
		}

	}
</style>